{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Pandas - read/write CSV files with HopsFS (HDFS)\n",
    "-------------------------------------------------------------------------------"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [],
   "source": [
    "from hops import hdfs\n",
    "from hops import pandas_helper as pandas\n",
    "import pandas as pd\n",
    "features = [\"Age\", \"Workclass\", \"fnlwgt\", \"Education\", \"Education-Num\", \"Marital Status\",\n",
    "            \"Occupation\", \"Relationship\", \"Race\", \"Sex\", \"Capital Gain\", \"Capital Loss\",\n",
    "            \"Hours per week\", \"Country\", \"Target\"]\n",
    "train_data = pandas.read_csv(hdfs.project_path() + \"/TourData/census/adult.data\", names=features, sep=r'\\s*,\\s*', engine='python', na_values=\"?\")\n",
    "\n",
    "train_data.info()\n",
    "\n",
    "pandas.write_csv(\"Resources/relative-path.csv\", train_data)\n",
    "pandas.write_csv(hdfs.project_path() + \"/Resources/full-path.csv\", train_data)"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "python-demo_featurestore_admin000__meb10000",
   "language": "python",
   "name": "python-demo_featurestore_admin000__meb10000"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.15"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}